package cc.wsyw126.java.stream;

import java.util.Random;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * Created by junpeng.yang on 16/8/24.
 */
public class GenerateStream {
    public static void main(String[] args) {
        Random seed = new Random();
        Supplier<Integer> random = seed::nextInt;
        Stream.generate(random).limit(10).forEach(System.out::println);

        System.out.println("-----------");

        IntStream.generate(() -> (int)(System.nanoTime()%100)).limit(10).forEach(num ->System.out.print(num + " "));
        System.out.println("\n--------------");

        //Stream.iterate
        Stream.iterate(0, n -> n +3).limit(10).forEach(num ->System.out.print(num + " "));

    }
}
